package util;

/**
 * cjianquan 2020/2/29
 */
public class StringUtils {

    public static String replaceLast(String source, String target,String replacement){
        int index = source.lastIndexOf(target);
        if(index==-1){
            return source;
        }
        int len = target.length();
        String result = source.substring(0,index)+replacement+source.substring(index+len);
        return result;
    }

    public static void main(String[] args) {
        String source="ManagePositionPoadddddd";
        String target="Po";
        String replacement="kkk";
        System.out.println(replaceLast(source,target,replacement));
    }
}
